import type { App } from "vue";
import { createRouter, createWebHashHistory } from 'vue-router'
import { constantRoutes } from './common/index'


const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
  scrollBehavior: () => ({ left: 0, top: 0 }),
})

/**
 * 重置路由
 */
export function resetRouter() {
  router.replace({ path: "/login" });
}

// 全局注册 router
export function setupRouter(app: App<Element>) {
  app.use(router);
}

export default router
